# 作者：苏子铭
# 时间：2021/11/19   15:21
# from tkinter import *
# import math
# WIDTH = 510;HEIGHT = 210
# ORIGIN_X = 2; ORIGIN_Y = HEIGHT / 2
# SCALE_X = 40;SCALE_Y = 100
# END_ARC = 360 * 2
# ox= 0;oy = 0;x = 0;y = 0
# arc = 0
# root = Tk()
# c = Canvas(root,bg = 'white', width = WIDTH, height = HEIGHT);c.pack()#创建显示背景墙
# c.create_text(200,20,text = 'y = sin(x)')
# c.create_line(0,ORIGIN_Y,WIDTH,ORIGIN_Y)
# c.create_line(ORIGIN_X,0,ORIGIN_X,HEIGHT)
# for i in range(0,END_ARC+1,10):
#     arc = math.pi * i * 2/360       #角度是小于180的角度
#     x = ORIGIN_X +arc * SCALE_X
#     y = ORIGIN_Y - math.sin(arc+math.pi * 90 * 2/360) * SCALE_Y
#     c.create_line(ox, oy, x, y)
#     ox = x;oy = y       #每次都是上一个点ox，oy和下一点相连


#海龟绘制正方形
# import turtle
# p = turtle.Turtle()
# p.color("red")
# p.pensize(3)
# p.speed(1)         #0最大，1最小
# p.goto(0,0)             #起点
# for i in range(4):
#     p.forward(100)
#     p.right(90)


# import turtle
# p = turtle.Turtle()
# p.speed(0)
# colors = ["red", "blue", "green", "yellow"]
# for i in range(50,100,1):
#     p.color(colors[i%4])
#     p.circle(i)                 #圆（直径）
#     p.left(89)
# for i in range(50,100,1):
#     p.color(colors[i%4])
#     p.circle(i)                 #圆（直径）
#     p.right(91)



#数据库表的创建，插入，更新，删除
import sqlite3
# con = sqlite3.connect(r"e:\pythonProject\sales.db")  #在链接中创建，有就打开
# con.execute("create table region (id primary key,name)") #创建table表格，两个参数
#


regions = [("021","上海"),("022","天津"),("023","重庆"),("024","沈阳")]
con = sqlite3.connect(r"e:\pythonProject\sales.db")
# con.execute("insert into region(id,name)values('020','广东')")
# con.execute("insert into region(id,name)values (?,?)",('001','北京'))
# con.executemany("insert into region(id,name)values(?,?)",regions)     #插入多行数据
con.execute("update region set name = ? where id = ?",('广州','020'))
n = con.execute("delete from region where id = ?",("021",))
print('删除了',n.rowcount,'行记录')
con.commit()                #提交
con.close()



con = sqlite3.connect(r"e:\pythonProject\sales.db")
cur = con.execute("select id, name from region")
for row in cur:
    print(row)












